package com.da.javatest.niuke.other;

import java.util.Arrays;

/**
 * @author JokerDa.
 * @date 2021/12/14 14:42
 * Description:https://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665?tpId=188&&tqId=38585
 * &rp=1&ru=/activity/oj&qru=/ta/job-code-high-week/question-ranking
 */
public class NC22Solution {
    public void merge(int A[], int m, int B[], int n) {
        int[] t = new int[m + n];
        int j = 0, k = 0;
        for (int i = 0; i < m + n; i++) {
            if (k >= n || (j < m && A[j] < B[k])) {
                t[i] = A[j];
                j++;
            } else {
                t[i] = B[k];
                k++;
            }
        }
        A = t;
        //System.arraycopy(t, 0, A, 0, m + n);
        System.out.println(Arrays.toString(A));
    }

    public static void main(String[] args) {
        NC22Solution s = new NC22Solution();
        //s.merge(new int[] {1, 2, 3}, 3, new int[] {2, 5, 6}, 3);
        s.merge(new int[] {4, 5, 6}, 3, new int[] {1, 2, 3}, 3);
    }
}
